{% extends 'rebs/layouts/base.html' %}

{% block title %}Rebs - 분양 수납 내역{% endblock %}

{% block content %}
    {% load static humanize widget_tweaks mathfilters %}

    <!-- Start Content-->
    <div class="container-fluid">

        <!-- start page title -->
        {% include 'rebs/partials/content_title.html' with  second_bs="분양 수납 관리" title="건별 수납 관리" %}
        <!-- end page title -->

        <div class="row">
            <form class="form-horizontal p-0 col-12" method="get">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">

                            {% with menu_order='2' %}
                                {% include 'rebs_cash/partials/head_menu_payment.html' %}
                            {% endwith %}

                            {% include 'rebs_cash/partials/payment_form_search_area.html' %}
                        </div>
                    </div>
                </div>
            </form>

            <div class="col-12">
                <div class="card {% if this_contract %}bg-info-lighten{% endif %}" style="background: #F3F4F8;">
                    <div class="card-body">
                        {% include 'rebs_cash/partials/payment_form_info.html' %}
                    </div>
                </div>
            </div>

            <div class="col-lg-7">
                <div class="card {% if request.GET.payment_id and not request.GET.contract %}bg-warning-lighten{% endif %}">
                    <div class="card-body">
                        {% include 'rebs_cash/partials/payment_form_form_table.html' %}
                    </div>
                </div>
            </div>

            <div class="col-lg-5">
                <div class="card">
                    <div class="card-body">
                        {% include 'rebs_cash/partials/payment_form_data_table.html' %}
                    </div>
                </div>
            </div>
        </div>
    </div> <!-- container -->

{% endblock %}

{% block third_party_js %}

    <script>
      const project = document.getElementById('id_project_sel')
      const type = document.getElementById('id_type')
      const contract = document.getElementById('id_contract')
      const q = document.getElementById('id_q')
      window.onload = function () {
        project.setAttribute('onchange', 'submit(this)')
        {% if not request.GET.payment_id %}
          document.getElementById('id_deal_date').value = '{{ today }}'
        {% else %}
          project.disabled = true
        {% endif %}

        type.value = '{{ request.GET.type }}'
        contract.value = '{{ request.GET.contract }}'
        q.value = '{{ request.GET.q }}'
      }

      function type_select(form) {
        contract.options[0].selected = true
        form.submit()
      }
    </script>

{% endblock %}
